package com.henry.consumer;

import com.henry.bean.MsgDTO;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MsgConsumer {

    @RabbitListener(queues = "DIRECT_MSG_QUEUE")
    public void consumer(MsgDTO msgDTO) {
        System.out.println("消费者收到消息:" + msgDTO);
    }

    //监听email队列
    @RabbitListener(queues = "TOPIC_MSG_QUEUE_EMAIL")
    public void emailConsumer(MsgDTO msgDTO, Message message, Channel channel) {
        log.info("emailConsumer msg:{}, message:{}, channel:{}", msgDTO, message, channel);
    }

    //监听sms队列
    @RabbitListener(queues = "TOPIC_MSG_QUEUE_SMS")
    public void smsConsumer(MsgDTO msgDTO, Message message, Channel channel) {
        log.info("smsConsumer msg:{}, message:{}, channel:{}", msgDTO, message, channel);
    }
}